package com.okami.domain.onlineshop;

import com.okami.common.AbstractEntity;
import com.okami.domain.onlineshop.converter.MapStringConverter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.persistence.*;
import java.util.Map;
import java.util.Set;

/**
 * @author: TanJingyu
 * @create: 2020-12-22 14:55
 **/
@EqualsAndHashCode(callSuper = true, exclude = "skus")
@Data
@Entity
@Table
@Accessors(chain = true)
@ToString
public class Goods extends AbstractEntity<Long> {
    private String name;
    @Convert(converter = MapStringConverter.class)
    private Map<String,String> specifications;
    private String information;

    @OneToMany(mappedBy = "goods")
    private Set<Sku> skus;

    @ManyToOne
    @JoinTable(name = "brand_goods", joinColumns = @JoinColumn(name = "goods_id", referencedColumnName = "id"),
        inverseJoinColumns = @JoinColumn(name = "brand_id", referencedColumnName = "id"))
    private Brand brand;

}
